package com.leetcode.partition12;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/1/3 9:06
 */
public class LC1185一周中的第几天 {

    private static final String[] week = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
    private static final int[] months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] s = reader.readLine().split("\\s+");
        int year = Integer.parseInt(s[0]), month = Integer.parseInt(s[1]), day = Integer.parseInt(s[2]);
        writer.write(dayOfTheWeek(day, month, year));
        writer.flush();
    }

    public static String dayOfTheWeek(int day, int month, int year) {
        //1970年12月31日是星期四
        int answer = 4;
        //计算出来传入的时间距离1971年1月1日有多少天
        for (int i = 1971; i < year; i++) answer += isLeap(i) ? 366 : 365;
        for (int i = 1; i < month; i++) {
            answer += months[i - 1];
            if (i == 2 && isLeap(year)) answer++;
        }
        return week[(answer + day) % 7];
    }

    private static boolean isLeap(int year) {
        return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
    }
}
